﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using SMTC.WebCommon.Common;

public partial class UserPower_UserPrint : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack &&Session["PrintGridviewColumns"] != null &&Session["PrintGridViewDataSource"] != null)
        {
            foreach (DataControlField dcf in (DataControlFieldCollection)Session["PrintGridviewColumns"])
            {
                this.GridviewUserPrint.Columns.Add(dcf);
               this.GridviewUserPrint.Columns.RemoveAt(4);
            }
            this.GridviewUserPrint.DataSource = Session["PrintGridViewDataSource"];
            this.GridviewUserPrint.DataBind();
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language='javascript'>");
            sb.Append("window.print();");
            sb.Append("</script>");
            ClientScript.RegisterStartupScript(this.GetType(), "print", sb.ToString());
           
        }
    }
    protected void GridviewUserPrint_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            int i = e.Row.RowIndex + 1;
            e.Row.Cells[0].Text = i.ToString();
        }
    }
}